package system.task.logger;

public class TaskLoggerUtil {

    public static StringBuilder buildContent(String time, String message, boolean newLine) {
        return buildContent(time, null, message, newLine);
    }

    public static StringBuilder buildError(String time, String message, boolean newLine) {
        String tag = "[ERROR]";
        return buildContent(time, tag, message, newLine);
    }

    public static StringBuilder buildContent(String time, String tag, String message, boolean newLine) {
        StringBuilder builder = new StringBuilder();
        if (time != null && !time.isEmpty()) {
            builder.append(time);
        }
        if (tag != null && !tag.isEmpty()) {
            if (builder.length() > 0) {
                builder.append(" ");
            }
            builder.append(tag);
        }
        if (message != null && !message.isEmpty()) {
            if (builder.length() > 0) {
                builder.append(" ");
            }
            builder.append(message);
        }
        if (newLine) {
            builder.append(System.lineSeparator());
        }
        return builder;
    }
}
